﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Web.UI.WebControls;

namespace MZaki.CustomActions
{
    class PostBackMenuItemTemplate :MenuItemTemplate ,IPostBackEventHandler   
    {
        public PostBackMenuItemTemplate()
        {
          //  this.ID ="MenuItem_"+ Guid.NewGuid().ToString();
        
        
        }
        protected override void EnsureChildControls()
        {
            if (!this.ChildControlsCreated)
            {
                base.EnsureChildControls();
                if (string.IsNullOrEmpty(this.ClientOnClickUsingPostBackEvent))
                {
                    this.ClientOnClickUsingPostBackEventFromControl(this,"%ListId%");
                }
            }
        }

        #region IPostBackEventHandler Members

        public void RaisePostBackEvent(string eventArgument)
        {
            EventHandler<EventArgs> handler = this.OnPostBack;
            if (handler != null)
            {
                handler(this, new EventArgs());
            }
        }
        public event  EventHandler<EventArgs> OnPostBack;

        #endregion
    }
}
